home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- Newsgroups: comp.lang.c
- Subject: Re: ANSI var-arglist processing
- Message-ID: <danpop.824161793@rscernix>
- From: danpop@mail.cern.ch (Dan Pop)
- Date: 12 Feb 96 21:49:53 GMT
- References: <311B1EF2.7673@exel.co.uk> <4ffuge$j3@spectator.cris.com>
- Organization: CERN European Lab for Particle Physics
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4ffuge$j3@spectator.cris.com> Crawford@cris.com (CRAWFORD) writes:
-
- >Jason Hambleton <jkh@exel.co.uk> writes:
- >>func2(char *fmt, ...)
- >>{
- >> va_list args;
- >> char buffer[81];
- >> va_start(args, fmt);
- >> vsprintf(buffer, fmt, args);
- >> va_end(args);
- >> printf("RESULT = (%s)\n", buffer);
- >>}
- >
- >>func1(char *fmt, ...)
- >>{
- >> /* How do I pass the arg-list from here, to the next function */
- >
- >> func2(fmt, ????????);
- >>}
- >
- > The answer lies in func2. How did you pass the variable
- >argument list to vsprintf?
-
- No, the answer isn't there. The prototype of vsprintf is
-
- int vsprintf(char *s, const char *format, va_list arg);
-
- i.e. vsprintf itself is _not_ a variadic function. OTOH, func2 _is_ a
- variadic function. The real analogy would be to pass the argument list
- to sprintf instead of vsprintf and this is not possible (which is the
- very reason for the existence of a function like vsprintf).
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-